<?php
// 接收前端传过来的参数
$name=$_POST['name'];
$pwd=$_POST['pwd'];
$age=$_POST['age'];

$conn = mysqli_connect('localhost', 'root', 'root', '2006');
mysqli_query($conn, "set charset 'utf8'");
mysqli_query($conn, "set character set 'utf8'");


$sql="insert into users (name,pwd,age) values ('$name','$pwd',$age)";

$res=mysqli_query($conn,$sql);
if ($res) {
  echo json_encode(array(
    "code" => 200,
    "body" => array(
      "msg" => "注册成功,立即登录"
    )
  ));
} else {
  echo json_encode(array(
    "code" => 201,
    "body" => array(
      "msg" => "网络异常，注册失败"
    )
  ));
}
?>